package com.swpu.course_schedule.service.Impl;

import com.swpu.course_schedule.POJO.Course.CourseArrange;
import com.swpu.course_schedule.POJO.Course.SingleWeekCourse;
import com.swpu.course_schedule.Util.SessionFactory;
import com.swpu.course_schedule.service.SingleWeekCourseService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class SingleWeekCourseImpl implements SingleWeekCourseService {
    @Override
    public SingleWeekCourse init(int week, int rid) {
        System.out.println("初始化 " + week + "周 " + rid + "教室");
        SingleWeekCourse weekCourse = new SingleWeekCourse();
        weekCourse.setWeek(week);
        weekCourse.setRid(rid);

        SqlSession session = SessionFactory.initSqlSessoin();
        List<CourseArrange> courseArranges =
                session.selectList("selectCourseByRidWeek", weekCourse);
        weekCourse.setCourseArranges(courseArranges);

        return weekCourse;
    }
}
